<template>
  <div class="stepBarHome">
    <div class="stepBarHome_left">
      <img class="stepBarHome_left_img" :src="isImg()" alt="">
      <div v-if="index + 1 < langth" class="stepBarHome_left_wire"></div>
    </div>
    <div class="stepBarHome_right">
      <div class="stepBarHome_right_title">
        <div
          :class="{ title_left: true, reject: isColor(1, 12, 8, 9, 10), sponsor: isColor(0, 11, 7, 20, 100), pass: isColor(2, 13, 11, 100, 100) }">
          {{ satusName() == '发起审批' && row.auditStatus == 11 && row.changeStatus == 1 ? '变更主播' : satusName() }}
        </div>
        <div class="title_right">{{ satusTime() }}</div>
      </div>

      <div v-if="satusName() === '发起变价'" class="stepBarHome_right_content">
        <div class="content_shiftPrice mb15">
          <div class="shiftPrice_img shiftPrice_img_lv">改</div>
          <div v-for="(item, ind) in row.changeMechanisms" :key="item.id">
            <div class="content_sponsor_item" v-if="item.cooperationMode">
              <div :class="{ item_one: true, item_one_hone: item.color === 'red' }">
                <div :class="{ jz_1: ind === 0, jz_2: ind === 1, jz_3: ind === 2 }"></div>
              </div>
              <div class="item_two" v-if="item.cooperationMode === '分佣'">
                <div class="item_two_left">￥{{ item.price }}
                </div>
                
              </div>
              <div class="item_two" v-if="item.cooperationMode === '供货'">
                <div class="item_two_title">成本</div>
                <div class="item_two_lan">￥{{ item.costPrice }}</div>
              </div>
            </div>
            <div class="item_two_right" v-if="item.cooperationMode === '分佣'">
                <div class="item_two_right_left">佣</div>
                <div class="item_two_right_right">{{ item.commission }}%+{{ item.brokerage || 0 }}%
                </div>
              </div>
            <div v-if="item.cooperationMode" class="item_three">【发货机制】{{ item.liveStreamingMechanism }}</div>
          </div>
        </div>
        <div class="content_shiftPrice">
          <div class="shiftPrice_img shiftPrice_img_lan">原</div>
          <div v-for="(item, ind) in row.hmChangeMechanismListTwo" :key="item.id">
            <div class="content_sponsor_item" v-if="item.cooperationMode">
              <div class="item_one">
                <div :class="{ jz_1: ind === 0, jz_2: ind === 1, jz_3: ind === 2 }"></div>
              </div>
              <div class="item_two" v-if="item.cooperationMode === '分佣'">
                <div class="item_two_left">￥{{ item.price }}
                </div>
                
              </div>
              <div class="item_two" v-if="item.cooperationMode === '供货'">
                <div class="item_two_title">成本</div>
                <div class="item_two_lan">￥{{ item.costPrice }}</div>
              </div>
            </div>
            <div class="item_two_right" v-if="item.cooperationMode === '分佣'">
              <div class="item_two_right_left">佣</div>
              <div class="item_two_right_right">{{ item.commission }}%+{{ item.brokerage || 0 }}%
              </div>
            </div>
            <div v-if="item.cooperationMode" class="item_three">【发货机制】{{ item.liveStreamingMechanism }}</div>
          </div>
        </div>
      </div>
      <div
        v-else-if="satusName() === '已驳回' && (row.firstStatus === 8 || row.firstStatus === 9 || row.firstStatus === 10)"
        class="stepBarHome_right_content">
        <div class="content_reject">
          <div
            :class="{ reject_item: true, reject_item_hong: row?.firstStatus == 8 || row?.firstStatus == 10, reject_item_lv: row?.firstStatus == 11 || row?.firstStatus == 9 }"
            v-if="row?.firstStatus == 10">
            <div class="reject_item_tag">核价驳回
            </div>
            <div class="reject_item_text">
              {{ row?.firstStatus == 8 || row?.firstStatus == 10 ? row?.auditPriceRemark : '审核通过' }}
            </div>
          </div>
          <div v-if='row?.firstStatus == 8 || row?.firstStatus == 9'
            :class="{ reject_item: true, reject_item_hong: row?.firstStatus == 8 || row?.firstStatus == 9, reject_item_lv: row?.firstStatus == 11 || row?.firstStatus == 10 }">
            <div class="reject_item_tag">资质驳回</div>
            <div class="reject_item_text">
              {{ row?.auditQualityRemark || '资审已通过' }}
            </div>
          </div>
        </div>
      </div>
      <div v-else-if="satusName() === '发起审批'" class="stepBarHome_right_content">
        <div v-if="row.auditStatus == 11 && row.auditRemark && row.changeStatus == 0"
          style="color: #FC2540;white-space: pre-wrap;">
          {{ row.auditRemark }}
        </div>
        <div v-if="row.auditStatus == 11 && row.auditRemark && row.changeStatus == 1"
          style="color: #FC2540;white-space: pre-wrap;">
          {{ row.auditRemark }}
        </div>
        <div v-else-if="mechanism() && auditStatus !== '22'" class="content_sponsor">
          <div v-for="(item, ind) in mechanism()" :key="item.id">
            <div class="content_sponsor_item" v-if="item.cooperationMode">
              <div class="item_one">
                <div :class="{ jz_1: ind === 0, jz_2: ind === 1, jz_3: ind === 2 }"></div>
              </div>
              <div class="item_two" v-if="item.cooperationMode === '分佣'">
                <div class="item_two_left">￥{{ item.price }}
                </div>
                
              </div>
              
              <div class="item_two" v-if="item.cooperationMode === '供货'">
                <div class="item_two_title">成本</div>
                <div class="item_two_lan">￥{{ item.costPrice }}</div>
              </div>
            </div>
            <div class="item_two_right" v-if="item.cooperationMode === '分佣'">
                <div class="item_two_right_left">佣</div>
                <div class="item_two_right_right">{{ item.commission }}%+{{ item.brokerage || 0 }}%
                </div>  
            </div>
            <div v-if="item.cooperationMode" class="item_three">【发货机制】{{ item.liveStreamingMechanism }}</div>
          </div>
        </div>
        <div v-else class="content_recruitManage">
          <div class="recruitManage_item">
            <span>招商部：</span>
            <span class="item_hui">{{ row?.createDeptName }}</span>
          </div>
          <div class="recruitManage_item">
            <span>招商员：</span>
            <span class="item_hui">{{ row?.createByName }}</span>
          </div>
          <div class="recruitManage_item">
            <span>预计补充合同时间：</span>
            <span class="item_hui">{{ row?.supplementTime && row?.supplementTime.split(' ')[0] }}</span>
          </div>
          <div class="recruitManage_item">
            <span>审批事由：</span>
            <span class="item_hui">{{ row?.recruiterRemark }}</span>
          </div>
        </div>
      </div>
      <div v-else-if="satusName() === '已通过' || satusName() === '发起入库'" class="stepBarHome_right_content"></div>
      <div v-else-if="satusName() === '变更主播'" class="stepBarHome_right_content" style="color:#FC2540">
        {{ isRemark() }}
      </div>
      <div v-else class="stepBarHome_right_content">
        {{ isRemark() }}
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps } from 'vue'
import icon_yibohui from '@/assets/porduct/icon_yibohui.png'
import icon_faqishenpi from '@/assets/porduct/icon_faqishenpi.png'
import icon_yitongguo from '@/assets/porduct/icon_yitongguo.png'
// import { userStore } from "@/store/user";
const props = defineProps(['row', 'index', 'langth', 'auditStatus', 'status', 'hmMechanismsList'])
// const user = userStore();
// row：步骤条里面每一条的数据
// index：步骤条中每一条的索引，主要判断最后一个步骤条不展示左侧的竖线
// langth：步骤条中一共有多少条数据，判断索引+1的时候大于或者等于总条数，最后一个步骤条不展示右侧的竖线
// status：0：审批中，1：已通过，2：已驳回
// auditStatus = 0:发起审批|发起资审,1:已驳回,2:已通过


// 步骤条中状态小图标的显示
const isImg = () => {
  // firstStatus==7:初审中-发起审批，firstStatus==8:初审中-全部驳回，firstStatus==9:初审中-资质驳回，firstStatus==10:初审中-价格驳回，firstStatus==11:初审通过
  // auditStatus
  // contractAuditStatus==0:无合同-发起，contractAuditStatus==1:无合同-驳回
  if (props.row.changeAuditStatus === 0 || props.row.stockStatus === 0 || props.row.auditStatus === 11 || props.row.firstStatus === 7 || props.row?.contractAuditStatus === 0 || props.row?.contractAuditStatus === 20 || props.row?.stockStatus === 20) {
    return icon_faqishenpi
  }
  if (props.row.changeAuditStatus === 1 || props.row?.stockStatus === 1 || props.row.auditStatus === 12 || props.row.firstStatus === 8 || props.row.firstStatus === 9 || props.row.firstStatus === 10 || props.row?.contractAuditStatus === 1) {
    return icon_yibohui
  }
  if (props.row.changeAuditStatus === 2 || props.row?.stockStatus === 2 || props.row.auditStatus === 13 || props.row.firstStatus === 11 || props.row?.contractAuditStatus === 2) {
    return icon_yitongguo
  }
}

// 步骤条中审批状态的显示
const satusName = () => {
  if (props.row?.changeAuditStatus === 0) {
    return '发起变价'
  }
  if (props.row?.changeAuditStatus === 2 && props.row?.stockAuditStatus === 2) {
      return '已接收'
  }
  if (props.row?.changeAuditStatus === 2 || props.row?.stockStatus === 2 || props.row.auditStatus === 13 || props.row.firstStatus === 11 || props.row?.contractAuditStatus === 2) {
    return '已通过'
  }
  if (props.row?.changeAuditStatus === 1 || props.row?.stockStatus === 1 || props.row.auditStatus === 12 || props.row.firstStatus === 8 || props.row.firstStatus === 9 || props.row.firstStatus === 10 || props.row?.contractAuditStatus === 1) {
    return '已驳回'
  }
  if (props.row?.stockStatus === 0) {
    return '发起入库'
  }
  if (props.row.auditStatus === 11 || props.row.firstStatus === 7 || props.row?.contractAuditStatus === 0) {
    return '发起审批'
  }
  if (props.row?.contractAuditStatus === 20 || props.row?.stockStatus === 20) {
    return '变更主播'
  }
  
}

const isColor = (type: number, typeOne: number, typeTwo: number, typeThree?: number, typeFour?: number) => {
  if (props.row?.changeAuditStatus == type || props.row?.stockStatus == type || props.row?.stockStatus === typeThree || props.row.auditStatus === typeOne || props.row?.firstStatus === typeTwo || props.row.firstStatus === typeThree || props.row.firstStatus === typeFour || props.row?.contractAuditStatus === type || props.row?.contractAuditStatus === typeThree) {
    return true
  } else {
    false
  }
}

// 步骤条中审批时间的显示
const satusTime = () => {
  if (props.row?.changeAuditStatus === 2 && props.row?.stockAuditStatus === 2) {
      return `${props.row?.stockUserName} ${props.row?.stockAuditTime}`
  }
  if (props.row?.changeAuditStatus === 0) {
    return `${props.row?.requestUserName||''} ${props.row?.createTime}`
  }
  if (props.row?.changeAuditStatus === 1 || props.row?.changeAuditStatus === 2) {
    return `${props.row?.pricingUserName||''} ${props.row?.pricingAuditTime}`
  }
  if (props.row?.stockStatus === 0 || props.row?.stockStatus === 20) {
    return `${props.row?.createByName||''} ${props.row?.createTime}`
  }
  if (props.row?.stockStatus === 1 || props.row?.stockStatus === 2) {
    return `${props.row?.auditor||''} ${props.row?.stockAuditTime}`
  }
  if (props.row?.auditStatus == 11 || props.row?.firstStatus == 7) {
    return `${props.row?.requestNickName||''} ${props.row?.requestTime}`
  }
  if (props.row?.auditStatus == 12 || props.row?.auditStatus == 13 || props.row?.firstStatus == 8 || props.row?.firstStatus == 9 || props.row?.firstStatus == 10 || props.row?.firstStatus == 11) {
    return `${props.row?.auditNickName||''} ${props.row?.auditTime}`
  }
  if (props.row?.contractAuditStatus === 0) {
    return `${props.row?.createByName||''} ${props.row?.createTime}`
  }
  if (props.row?.contractAuditStatus === 1 || props.row?.contractAuditStatus === 2) {
    return `${props.row?.auditor||''} ${props.row?.auditTime}`
  }
  if (props.row?.contractAuditStatus === 1 || props.row?.contractAuditStatus === 2) {
    return `${props.row?.auditor||''} ${props.row?.auditTime}`
  }
  if (props.row?.contractAuditStatus === 20) {
    return `${props.row?.createByName||''} ${props.row?.auditTime}`
  }
}

const isRemark = () => {
  if (props.row?.changeAuditStatus === 1) {
    return props.row?.pricingAuditRemark
  } else if (props.row?.auditStatus === '1') {
    return props.row?.auditRemark
  } else if (props.row?.stockStatus === 1) {
    return props.row?.stockAuditRemark
  } else if (props.row?.auditStatus == 12) {
    return props.row?.auditRemark
  } else {
    return props.row?.remark || props.row?.stockAuditRemark
  }
}

const mechanism = () => {
  if (props.row?.firstStatus === 7 || props.row?.auditStatus === 11) {
    return props.row?.mechanismLogList && props.row?.mechanismLogList.length ? props.row?.mechanismLogList : []
  } else {
    return props.hmMechanismsList && props.hmMechanismsList.length ? props.hmMechanismsList : []
  }
}
</script>

<style lang="less" scoped>
.stepBarHome {
  width: 100%;
  display: flex;

  .stepBarHome_left {
    margin-right: 10px;
    display: flex;
    flex-flow: column;
    align-items: center;

    .stepBarHome_left_img {
      width: 18px;
      height: 18px;
      transform: translateY(-2px);
      margin-bottom: 3px;
    }

    .stepBarHome_left_wire {
      flex: 1;
      width: 1px;
      background: #E6E6E6;
      background: #0094FF;
      margin-bottom: 5px;
    }
  }

  .stepBarHome_right {
    flex: 1;
    min-width: 0;

    .stepBarHome_right_title {
      width: 100%;
      height: 15px;
      margin-bottom: 5px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .title_left {
        font-weight: 500;
        font-size: 16px;
      }

      .reject {
        color: #FC2540;
      }

      .sponsor {
        color: #0094FF;
      }

      .pass {
        color: #19D11B;
      }

      .title_right {
        font-weight: 400;
        font-size: 12px;
        color: #8492AD;
      }
    }

    .stepBarHome_right_content {
      min-height: 35px;
      text-align: right;
      padding: 5px 0 10px;
      font-weight: 400;
      font-size: 14px;
      color: #1A1B1C;
      box-sizing: border-box;
      word-wrap: break-word;

      .content_sponsor {
        width: 100%;
        overflow-x: auto;
        background: linear-gradient(0deg, #FBFCFE 0%, #EFF6FF 100%);
        border-radius: 10px;
        padding: 15px 5px 1px 10px;
        box-sizing: border-box;
      }

      .content_recruitManage {
        background: linear-gradient(#EFF6FF 0%, #FBFCFE 100%);
        border-radius: 10px;
        padding: 15px 5px 1px 10px;
        box-sizing: border-box;

        .recruitManage_item {
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-bottom: 15px;
          display: flex;
          justify-content: space-between;

          .item_hui {
            color: #8492AD;
            flex: 0.9;
            min-width: 0;
            word-break: break-all;
          }
        }
      }

      .content_shiftPrice {
        overflow-x: auto;
        white-space: nowrap;
        padding: 15px 1px 5px 10px;
        box-sizing: border-box;
        position: relative;
        background: linear-gradient(#FBFCFE 0%, #EFF6FF 100%);
        border-radius: 10px;

        .shiftPrice_img {
          width: 30px;
          height: 30px;
          background-repeat: no-repeat;
          background-size: 100% 100%;
          position: absolute;
          top: 0;
          right: 0;
          z-index: 1;
          display: flex;
          align-items: center;
          justify-content: center;
          font-weight: 500;
          font-size: 16px;
          color: #FFFFFF;
        }

        .shiftPrice_img_lv {
          background-image: url("@/assets/newui/details/icon_gai@2x.png");
        }

        .shiftPrice_img_lan {
          background-image: url("@/assets/newui/details/icon_yuan@2x.png");
        }

        .item_three{
          color: #8492AD;
        }
      }

      .content_reject {
        width: 100%;
        background: linear-gradient(0deg, #FEFBFB 0%, #FFEFEF 100%);
        border-radius: 10px;
        padding: 15px 10px 1px;
        box-sizing: border-box;

        .reject_item {
          width: 100%;
          margin-bottom: 15px;
          display: flex;
          align-items: center;
          font-weight: 400;
          font-size: 14px;

          .reject_item_tag {
            // padding: 5px 0px;
            width: 70px;
            height: 24px;
            border-radius: 2px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 400;
            font-size: 14px;
            color: #FFFFFF;
            margin-right: 10px;
            box-sizing: border-box;
          }

          .reject_item_text {
            flex: 1;
            min-width: 0;
            font-weight: 400;
            font-size: 14px;
            text-align: left;
            color: #FC2540;
          }
        }

        .reject_item_hong {
          color: #1A1B1C;

          .reject_item_tag {
            background: #FC2540;
          }
        }

        .reject_item_lv {
          color: #19D11B;

          .reject_item_tag {
            background: #19D11B;
          }
        }
      }

    }
  }
}

.content_sponsor_item {
  white-space: nowrap;
  text-align: left;

  .item_one {
    display: inline-block;
    width: 56px;
    height: 24px;
    background: linear-gradient(146deg, #0064FF 0%, #008FFF 100%);
    border-radius: 2px;
    line-height: 24px;
    text-align: center;
    font-weight: 400;
    font-size: 14px;
    color: #FFFFFF;
    vertical-align: middle;
    margin-right: 10px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
  }

  .jz_1 {
    width: 45px;
    height: 13px;
    background: url("@/assets/newui/details/icon_jizhiyibai@2x.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }

  .jz_2 {
    width: 45px;
    height: 13px;
    background: url("@/assets/newui/details/icon_jizhierbai@2x.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }

  .jz_3 {
    width: 45px;
    height: 13px;
    background: url("@/assets/newui/details/icon_jizhisanbai@2x.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }

  .item_one_hone {
    background: red;
  }

  .item_two {
    display: inline-block;
    min-width: 130px;
    vertical-align: middle;
    margin-right: 10px;

    .item_two_left {
      display: inline-block;
      font-weight: 400;
      font-size: 16px;
      color: #FC2540;
      vertical-align: middle;
      margin-right: 10px;
    }

    

    .item_two_title {
      display: inline-block;
      font-weight: 400;
      font-size: 14px;
      color: #0094FF;
      vertical-align: middle;
    }

    .item_two_lan {
      display: inline-block;
      margin-left: 10px;
      font-weight: 400;
      font-size: 16px;
      color: #0094FF;
      vertical-align: middle;
    }
  }

  
}
.item_two_right {
  display: flex;
  background: linear-gradient(136deg, #E9D1A5 0%, #CEA46C 100%);
  border-radius: 2px;
  height: 18px;
  margin-top: 10px;
  width: fit-content;
  vertical-align: middle;

  .item_two_right_left {
    width: 22px;
    background: #1B1714;
    border-radius: 2px;
    font-weight: 400;
    font-size: 12px;
    color: #CEA46C;
    line-height: 18px;
    text-align: center;
    vertical-align: middle;
  }

  .item_two_right_right {
    line-height: 18px;
    text-align: center;
    font-weight: 500;
    font-size: 12px;
    color: #1B1714;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0 5px;
  }
}
.item_three {
    width: 100%;
    word-wrap: break-word;
    word-break: break-all;
    white-space: normal;
    text-align: left;
    padding: 7px 0;
    font-weight: 500;
    font-size: 14px;
    color: #0094FF;
    line-height: 20px;
  }

.mb15 {
  margin-bottom: 15px;
}
</style>